﻿using System;
using System.Windows.Forms;
using Castle.Windsor.Configuration.Interpreters.XmlProcessor;
using OFX.Aggregator.Infrastructure;
using ApplicationClass = System.Windows.Forms.Application;

namespace OFX.Aggregator.Application
{
	internal static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		private static void Main()
		{
			ApplicationClass.EnableVisualStyles();
			ApplicationClass.SetCompatibleTextRenderingDefault(false);

			try
			{
				SingletonContainer.Setup(new WindsorContainer());
			}
			catch (ConfigurationProcessingException cpex)
			{
				MessageBox.Show((cpex.InnerException ?? cpex).Message, ApplicationClass.ProductName, MessageBoxButtons.OK,
				                MessageBoxIcon.Error);
				return;
			}

			ApplicationClass.Run(SingletonContainer.Resolve<OFXAggregatorMainForm>("MainForm"));
		}
	}
}